<?php


class logClassAction extends Action
{
    public function slogsAjax() {
        $page = $this->request('page', 1);
        $limit = $this->request('limit', 15);
        $username = $this->request('uname');
        $pdfname = $this->request('pdfname');
        $sdate = $this->request('sdate');
        $edate = $this->request('edate');
        $where = "1=1";

        if(!empty($username)){
            $username = trim($username);
            $where .=" and b.name like '%".$username."%'";
        }

        if(!empty($pdfname)){
            $pdfname = trim($pdfname);
            $where .=" and a.doc_name like '".$pdfname."%'";
        }

        if ($sdate) {
            $where .= " and a.create_time >= '".$sdate. " 00:00:00'";
        }
        if ($edate) {
            $where .= " and a.create_time <='". $edate. " 23:59:59'";
        }

        $sql = "select a.id from [Q]zbcg_signature_log as a inner join [Q]admin as b on a.seal_owner = b.id where ".$where;
        $sqllist = "select a.id,a.create_time,a.seal_name,a.doc_name,a.ip,b.name from [Q]zbcg_signature_log as a inner join [Q]admin as b on a.seal_owner = b.id where ".$where. ' order by create_time desc limit '.($page-1)*$limit.','.$limit;

        $number = $this->db->getall($sql);
        $lists = $this->db->getall($sqllist);
        $data	= array(
            'totalCount'=> count($number),
            'rows'		=> $lists
        );
        return json_encode($data);
    }
}